{template 'common/header-storex'}
<div class="wn-main">
	<div class="wn-main__head">概况</div>
	<div class="wn-main__content">
		<div class="wn-tabs">
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_stat', array('storeid' => $_GPC['storeid'], 'op' => 'order_stat'))}">订单趋势图</a>
			</div>
			<div class="wn-tabs__item wn-tabs__item--active">
				<a class="wn-tabs__link" href="javascript:;">营业额趋势图</a>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="panel panel-default wn-panel">
			<div class="panel-heading">
				<form action="" id="stat-form">
					<input type="hidden" name="c" value="site">
					<input type="hidden" name="a" value="entry">
					<input type="hidden" name="do" value="shop_stat">
					<input type="hidden" name="op" value="sales_stat">
					<input type="hidden" name="storeid" value="{$storeid}">
					<input type="hidden" name="m" value="wn_storex">
					{php echo tpl_form_field_daterange('time', array('starttime' => date('Y-m-d', $starttime),'endtime' => date('Y-m-d', $endtime)));}
				</form>
			</div>
			<div class="wn-dashboard">
				<div class="wn-dashboard__order wn-flex">
					<div class="wn-flex__item">
						<p>{php echo date('Y-m-d', $starttime)}--{php echo date('Y-m-d', $endtime)}</p>
						<span>总金额（元）：{$total_sales}</span>
					</div>
				</div>
			</div>
			<div class="panel-body">
				<div id="myChart" style="height: 500px"></div>
				<table class="table table-hover table-bordered wn-table" >
					<thead class="navbar-inner">
					<tr>
						<th>日期</th>
						<th>营业额(元)</th>
						<th>详情</th>
					</tr>
					</thead>
					<tbody>
					{loop $sales_stat $date $sales}
					<tr>
						<td>{$date}</td>
						<td>{$sales}</td>
						<td>
							<a href="{php echo $this->createWebUrl('shop_order', array('op' => 'display', 'storeid' => $_GPC['storeid'], 'date' => array('start' => date('Y-m-d', strtotime($date)), 'end' => date('Y-m-d', strtotime($date)))))}">查看订单</a>
						</td>
					</tr>
					{/loop}
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	require({
		paths: {
			'echart': "{php echo SCRIPT_URL . '/echarts'}"
		}
	});
	var chart_data = {php echo json_encode($chart_data);};
	require(['echart', 'daterangepicker'], function(echarts) {
		$('.daterange').on('apply.daterangepicker', function(ev, picker) {
			$('#stat-form')[0].submit();
		});
		var myChart = echarts.init(document.getElementById('myChart'));
		// 指定图表的配置项和数据
		option = {
			title: {
				text: '营业额趋势图'
			},
			tooltip: {
				trigger: 'axis'
			},
			legend: {
				data:['营业额']
			},
			grid: {
				left: '3%',
				right: '4%',
				bottom: '3%',
				containLabel: true
			},
			toolbox: {
				feature: {
					saveAsImage: {}
				}
			},
			xAxis: {
				type: 'category',
				boundaryGap: false,
				data: chart_data.label
			},
			yAxis: {
				type: 'value'
			},
			series: [
				{
					name:'营业额',
					type:'line',
					stack: '总量',
					data: chart_data.series_data
				}
			]
		};
		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
	});
</script>
{template 'common/footer-storex'}